﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using GoblinXNA;
using GoblinXNA.SceneGraph;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GoblinXNA.Graphics;
using GoblinXNA.Graphics.Geometry;

namespace ping
{
    public class Ball : GeometryNode
    {
        static GoblinXNA.Graphics.Model ballModel = new Sphere(1, 20, 20);
        TransformNode t;
        public TransformNode Trans
        {
            get { return t; }
        }

        public Ball(Vector3 position)
        {
            //this.Name = "Ball_" + numBalls;
            this.Model = ballModel;
            this.Physics.MaterialName = "ball";
            this.AddToPhysicsEngine = true;
            this.Physics.ApplyGravity = true;
            this.Physics.Interactable = true;
            this.Physics.Collidable = true;
            this.Physics.Shape = GoblinXNA.Physics.ShapeType.Sphere;
            this.Physics.Mass = 1f;
            

            // Make this this model cast and receive shadows
            this.Model.CastShadows = true;
            this.Model.ReceiveShadows = true;

            //t = new TransformNode("Ball_Transform_"+numBalls);
            t = new TransformNode();
            t.Translation = position;

            // Create a material to apply to the this model
            Material ballMaterial = new Material();
            ballMaterial.Diffuse = Color.OrangeRed.ToVector4();
            ballMaterial.Specular = Color.White.ToVector4();
            ballMaterial.SpecularPower = 10;

            // Create a sound node for the this
            //SoundNode sound = new SoundNode("Ball_Sound_" + numBalls++);
            SoundNode sound = new SoundNode();

            this.Material = ballMaterial;
            this.AddChild(sound);
            t.AddChild(this);
        }
    }
}
